import request from '@/utils/request'

// 查询巡检计划列表
export function listInspectionPlan(query) {
  return request({
    url: '/ldzl-sb/inspection/plan/list',
    method: 'get',
    params: query
  })
}

// 查询巡检计划详细
export function getInspectionPlan(planId) {
  return request({
    url: '/ldzl-sb/inspection/plan/' + planId,
    method: 'get'
  })
}

// 新增巡检计划
export function addInspectionPlan(data) {
  return request({
    url: '/ldzl-sb/inspection/plan',
    method: 'post',
    data: data
  })
}

// 修改巡检计划
export function updateInspectionPlan(data) {
  return request({
    url: '/ldzl-sb/inspection/plan',
    method: 'put',
    data: data
  })
}

// 删除巡检计划
export function deleteInspectionPlan(planId) {
  return request({
    url: '/ldzl-sb/inspection/plan/' + planId,
    method: 'delete'
  })
}

// 更新巡检计划状态
export function updateInspectionPlanStatus(planId, status) {
  return request({
    url: '/ldzl-sb/inspection/plan/changeStatus',
    method: 'put',
    data: {
      planId,
      status
    }
  })
}

// 生成巡检单
export function generateInspectionRecord(planId) {
  return request({
    url: '/ldzl-sb/inspection/plan/generate/' + planId,
    method: 'post'
  })
}

// 获取巡检计划可用设备
export function getAvailableEquipments(typeId) {
  return request({
    url: '/ldzl-sb/sb/equipment/list/byType',
    method: 'get',
    params: { typeId: typeId }
  })
}

// 获取所有可用设备列表（不按类型过滤）
export function getAllEquipments() {
  return request({
    url: '/ldzl-sb/sb/equipment/list/all',
    method: 'get'
  })
}

// 获取巡检配置列表
export function getInspectionConfigList() {
  return request({
    url: '/ldzl-sb/inspection/config/list',
    method: 'get'
  })
}

// 获取设备列表
export function getEquipmentList(query) {
  return request({
    url: '/ldzl-sb/sb/equipment/list',
    method: 'get',
    params: query
  })
} 

// 检查计划编号唯一性
export function checkPlanCodeUnique(planCode) {
  return request({
    url: '/ldzl-sb/inspection/plan/check/' + planCode,
    method: 'get'
  });
}

// 生成巡检计划编号
export function generatePlanCode() {
  return request({
    url: '/ldzl-sb/inspection/plan/generate/code',
    method: 'get'
  });
} 